package missile;

import battlestein.Agent;
/**
 * 
 * @author LocoRocoBattleStein
 *
 */
public class Bullet extends Missile {
	
	Agent target;
	/**
	 * Constructor
	 * @param posX
	 * @param posY
	 * @param finalX
	 * @param finalY
	 * @param velocity
	 * @param effectLife
	 * @param effectVelocity
	 * @param target
	 */
	public Bullet(int posX, int posY, int finalX, int finalY, double velocity, int effectLife, int effectVelocity, Agent target) {
		super(posX, posY, finalX, finalY, velocity, effectLife, effectVelocity);
		this.setImgMissile("medias/projectileGun.png");
		
		this.target = target;
	}
	
	public void updatePosition() {
		this.setFinalX((int)target.getX());
		this.setFinalY((int)target.getY());
		
		this.setDirection();
		
		this.setPosX( this.getPosX() + (this.getDirX() * this.getVelocity()));
		this.setPosY( this.getPosY() + (this.getDirY() * this.getVelocity()));
	}

}
